<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>对象</title>
</head>

<body>
    <script>
        let obj = {
            name: "White",
            age: "20"
        }
        obj.sayHello = function sayHello(a){
            console.log(a)
        }
        obj.sayHello("你好")
        console.log(obj)
        console.log(obj.name)
        console.log(obj['age'])


        let obj1 = new Object()
        obj1.name = 'Black'
        obj1.age = 18
        obj1.height = 180
        console.log(obj1.name)


        function Person(name,price,time,id){
            this.name = name
            this.price = price
            this.time = time
            this.id = id
            this.sayHi = a =>{
                console.log(a)
            }
        }
        let obj2 = new Person("红楼梦",23,"9月28日","000001")
        console.log(obj2)
        console.log(obj2.time + "编号序列为" + obj2.id + "的书" + obj2.name + "被借出，逾期赔偿" + obj2.price + "元")
        obj2.sayHi("再见")

        function Sum(num1, num2, num3) {
            this.num1 = num1;
            this.num2 = num2;
            this.num3 = num3;
            this.sum = function () {
                 return this.num2 ** 2 - 4 * this.num1 * this.num3;
                };
            }

        let su = new Sum(3, 4, 5);
        console.log(su);    
        console.log(su.sum()); 
        
    </script>
</body>

</html>